package logic

import (
	"cloud-disk/core/internal/svc"
	"cloud-disk/core/internal/types"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserFileDeleteLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserFileDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFileDeleteLogic {
	return &UserFileDeleteLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserFileDeleteLogic) UserFileDelete(req *types.UserFileDeleteRequest, UserIdentity string) (resp *types.UserFileDeleteResponse, err error) {
	resp = new(types.UserFileDeleteResponse)
	err = l.svcCtx.UserRepostioryModel.DeleteFileByIdentity(req.Identity, UserIdentity)
	if err != nil {
		resp.Message = "删除失败 " + err.Error()
		resp.Code = 100
		return resp, nil
	}
	resp.Message = "删除成功"
	resp.Code = 200
	return resp, nil
}
